<div class="content">
    <div id="example_title">
        <h1>Base64 Encoding and Decoding</h1>
        All server side languages provide base64 encoding and decoding functionality, but not JavaScript. You can use w2utils for all your
        base64 needs.
    </div>
    <div id="example_view"></div>
    <div id="example_code"></div>
</div>

<!--CODE-->
<textarea id="encode" class="w2ui-input" style="width: 100%; height: 60px">
This <a href="http://link">is some</a> HTML <b>text</b> to be encoded.
Also counld     have     spaces    that    can be removed.
</textarea>
<br><br>
<button class="w2ui-btn btn-w2utils" id="base64encode">Encode base64</button>
<button class="w2ui-btn btn-w2utils" id="base64decode">Decode base64</button>
<span style="color: gray; padding: 10px">|</span>
<button class="w2ui-btn btn-w2utils" id="encodeTags">Encode HTML Tags</button>
<button class="w2ui-btn btn-w2utils" id="decodeTags">Decode HTML Tags</button>
<div style="height: 20px"></div>
<button class="w2ui-btn btn-w2utils" id="stripTags">Strip HTML Tags</button>
<button class="w2ui-btn btn-w2utils" id="stripSpaces">Strip Extra Spaces (2.0+)</button>
<button class="w2ui-btn" id="showSha">Calculate sha256  (2.0+)</button>

<!--CODE-->
<script type="module">
import { w2utils, query, w2popup } from '__W2UI_PATH__'

query('.btn-w2utils').on('click', (event) => {
    let method = event.target.id
    query('#encode').val(w2utils[method](query('#encode').val()))
})

query('#showSha').on('click', async () => {
    w2popup.open({
        height: 200,
        width: 500,
        title: 'Sha',
        body: `<div class="w2ui-centered">${await w2utils.sha256(query('#encode')[0].value)}</div>`,
        actions: {
            Ok() { w2popup.close() }
        }
     })
})
</script>

<!--CODE-->
